package edu.uaskl.jqf.model.matrix;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import edu.uaskl.jqf.model.Complex;

public class MatrixSolverEigen {
    private final List<Complex> eigenValues;
    private final Complex[][] eigenVectors;

    public MatrixSolverEigen(final Complex[] eigenValues, final Complex[][] eigenVectors) {
        this(Arrays.asList(eigenValues), eigenVectors);
    }

    public MatrixSolverEigen(final List<Complex> eigenValues, final Complex[][] eigenVectors) {
        this.eigenValues = Collections.unmodifiableList(new ArrayList<>(eigenValues));
        this.eigenVectors = eigenVectors;
    }

    /** Returns a (unmodifiable) list of the eigenvalues */
    public List<Complex> getEigenValues() {
        return eigenValues;
    }

    // TODO copy
    public Complex[][] getEigenVectors() {
        return eigenVectors;
    }

    @Override
    public String toString() {
        final StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("eigenValues:").append("\n");
        stringBuilder.append(eigenValues).append("\n");
        stringBuilder.append("eigenVectors:").append("\n");
        stringBuilder.append(MatrixComplex.createMatrixBasedOnArray2d(eigenVectors)).append("\n");
        return stringBuilder.toString();
    }
}
